#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, x;
ll a[N], b[N], c[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> x;
  rep(i, 1, n) cin >> a[i] >> b[i];
  rep(i, 1, n) c[i] = a[i] + b[i];
  ll h = *min_element(c + 1, c + n + 1);
  ll mx = a[1] + x, mn = max(0ll, h - b[1] - x);
  rep(i, 2, n) {
    ll l = max(0ll, h - b[i]), r = a[i];
    ll d = 0;
    if (r < mn) d = mn - r;
    if (l > mx) d = l - mx;
    if (d) mn = max(0ll, mn - d), l = max(0ll, l - d), h -= d;
    mx = min(mx, r) + x;
    mn = max(0ll, max(mn, l) - x);
  }
  ll sum = accumulate(c + 1, c + n + 1, -1ll * n * h);
  cout << sum;
  return 0;
}